/*
 * @Author: zi.yang
 * @Date: 2021-10-02 23:47:02
 * @LastEditors: zi.yang
 * @LastEditTime: 2021-10-03 00:07:42
 * @Description: In User Settings Edit
 * @FilePath: \project-management\services\SysLoginLog.js
 */
const SysLoginLog = require('../models/sys_login_log');

/**
 * @description:添加新的登录日志
 * @param { Object } userInfo
 * @return { Boolean }
 */
exports.addLoginLog = async function (loginInfo) {
  try {
    await SysLoginLog.create(loginInfo);
    return true;
  } catch (e) {
    console.log(e);
    return false;
  }
};

/**
 * @description:  获取所有登录日志
 * @param { function } cb
 * @return: cb()
 */
exports.findAllLoginLog = async function (cb) {
  try {
    const loginLog = await SysLoginLog.findAndCountAll();
    return cb({ code: 200, msg: 'success', data: loginLog });
  } catch (e) {
    console.log(e);
    return cb({ code: 500, msg: 'error', data: [] });
  }
};
